{% extends "base/basehead.html" %}
{% block title %}
    NiceNovel登录
{% endblock %}
{% block content %}
    <div class="container">
        <br><br><br><br><br><br><br><br>
        <div class="row">
            <div class="col-md-4">
            </div>
            <div class="col-md-4">
                <div class="row">
                    <form method="post" action="{% url 'signin' %}">
                        <div class="form-group">
                            <label for="exampleInputEmail1">邮箱</label>
                            <input type="email" class="form-control" name="email" id="exampleInputEmail1"
                                   aria-describedby="emailHelp">
                            <small id="emailHelp" class="form-text text-muted"></small>
                        </div>
                        <div class="form-group">
                            <label for="exampleInputPassword1">密码</label>
                            <input type="password" class="form-control" name="password" id="exampleInputPassword1">
                        </div>

                        <div class="form-row">
                            <div class="col-md-6">
                                <input type="text" name="yzm" class="form-control" placeholder="验证码">
                            </div>
                            <div class="col-md-6">
                                <button type="button" id="yzm" class="btn btn-info">获取验证码</button>
                            </div>
                        </div>
                        <div class="row">

                            <div class="col-md-6">
                                <br>
                                <button type="submit" class="btn btn-primary">登录</button>

                            </div>
                            <div class="col-md-6">
                                <br>
                                <a type="button" href="formregister" class="btn btn-primary">注册</a>
                            </div>
                        </div>
                    </form>
                </div>

            </div>
            <div class="col-md-4">
            </div>
        </div>
    </div>
{% endblock %}
{% block js %}
    <script type="text/javascript">
        $(document).ready(function () {
            $('#yzm').click(
                function () {
                    $.ajax({
                        type: "POST",
                        url: "{% url 'getcode' %}",
                        data: {"email": $("#exampleInputEmail1").val()},
                        datatype: 'json',
                        success: function (data) {
                            $("#yzm").text(data.mes)
                        },
                        error: function () {
                            $("#yzm").text("发送失败")
                        }
                    });
                });
        });
    </script>
{% endblock %}

